<script type="text/html" template>
  <link rel="stylesheet" href="{{ layui.setter.base }}style/css/reset.css">
  <link rel="stylesheet" href="{{ layui.setter.base }}style/css/transaction/cash.css">
  <link rel="stylesheet" href="{{ layui.setter.base }}style/page.css">
</script>
<style>
  .layui-form-label {
    width: 80px;
    font-size: 10px;
    margin-right: 10px;
  }

  .layui-input {
    width: 150px;
  }

  .footer {
    margin: 20px;
  }

  .boxQuery {
    display: none;
    z-index: 999;
    top: 0;
    position: absolute;
    width: 100%;
    background-color: #ffffff;
    margin: 0 auto;
    padding: 0 0 50px 0;
    text-align: left;
  }

  .boxQuery .layui-form-item {
    margin: 10px 0;
  }

  .sure {
    width: 70px;
    height: 25px;
    font-size: 11px;
    border-radius: 15px;
    background-color: #FF4C4C;
  }

  .close {
    width: 70px;
    height: 25px;
    border-radius: 15px;
    background-color: #3D8CC9;
  }

  .reset {
    width: 70px;
    height: 25px;
    border-radius: 15px;
    background-color: #FF9F0C;
  }
</style>
<form class="boxQuery layui-form" lay-filter="layuiadmin-form-tags" id="layuiadmin-form-tags">
  <ul class="layui-row">
    <li class="layui-col-md4 layui-col-sm4">
      <div class="flex layui-form-item">
        <label class="layui-form-label">工单状态</label>
        <div class="layui-input-block">
          <select name="fil05">
            <option value="">全部</option>
            <option value="0">未提交</option>
            <option value="1">待审核</option>
            <option value="6">OA送审中</option>
            <option value="9">归档已完成</option>
          </select>
        </div>
      </div>
      <div class="flex layui-form-item">
        <label class="layui-form-label"> 申请日期</label>
        <div class="layui-input-block">

          <input type="text" style="color: #666;" placeholder="请选择日期" name="fil10" id="time" class="layui-input">
        </div>
      </div>
      <div class="flex layui-form-item">
        <label class="layui-form-label">设备型号</label>
        <div class="layui-input-block">

          <input type="text" name="fic02" placeholder="请输入设备型号" autocomplete="off" class="layui-input">

        </div>
      </div>
      <div class="flex layui-form-item">
        <label class="layui-form-label"> 供应商</label>
        <div class="layui-input-block">
          <input type="text" name="pmc081" placeholder="请输入供应商" autocomplete="off" class="layui-input">
        </div>
      </div>
    </li>
    <li class="layui-col-md4 layui-col-sm4">
      <div class="flex layui-form-item">
        <!-- *** -->
        <label class="layui-form-label">工单名称</label>
        <div class="layui-input-block">
          <input type="text" name="tcReqName" placeholder="请输入工单名称" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="flex layui-form-item">
        <label class="layui-form-label"> OA流程编号</label>
        <div class="layui-input-block">
          <input type="text" name="fil02" placeholder="请输入OA流程编号" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="flex layui-form-item">
        <label class="layui-form-label"> 设备编号</label>
        <div class="layui-input-block">
          <input type="text" name="tcDetailFia01" placeholder="请输入设备编号" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="flex layui-form-item">
        <label class="layui-form-label"> 设备系列</label>
        <div class="layui-input-block">
          <input type="text" name="tcSeriesName" placeholder="请输入设备系列" autocomplete="off" class="layui-input">
        </div>
      </div>
    </li>
    <li class="layui-col-md4 layui-col-sm4">
      <div class="flex layui-form-item">
        <label class="layui-form-label">工单编号</label>
        <div class="layui-input-block">
          <input type="text" name="fil01" placeholder="请输入工单编号" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="flex layui-form-item">
        <label class="layui-form-label">申请人工号</label>
        <div class="layui-input-block">
          <input type="text" name="gen02" placeholder="请输入申请人工号" autocomplete="off" class="layui-input" id="gen02">
        </div>
      </div>
      <div class="flex layui-form-item">
        <label class="layui-form-label"> 设备类型</label>
        <div class="layui-input-block">
          <input type="text" name="fic02" placeholder="请输入设备类型" autocomplete="off" class="layui-input">
        </div>
      </div>
    </li>

  </ul>
  <div class="footer layui-btn-container" style="justify-content: center">
    <button lay-submit lay-filter="LAY-submit" class="sure layui-btn layui-btn-radius layui-btn-primary">
      确定
    </button>
    <button lay-submit lay-filter="LAY-close" class="close layui-btn layui-btn-radius layui-btn-primary">
      关闭
    </button>
    <button lay-submit lay-filter="LAY-reset" class="reset layui-btn layui-btn-radius layui-btn-primary">
      清空
    </button>
  </div>
</form>
<div class="box layui-fluid layui-row">
  <div class="layui-card box">
    <div class="btn-box layui-btn-container layui-row" style="text-align: left;vertical-align: middle;">
      <button class="search-two-btn add-btn create" data-type="add">
        <i class="layui-icon layui-icon-add-circle" style="font-size: 15px; color: #1E9FFF;"></i>
        <span>信息变更工单</span>
      </button>
      <button class="search-two-btn search " data-type="query">
        <span>条件查询</span>
      </button>
    </div>
    <div class="layui-card-body">
      <table class="layui-table" id="LAY-app-content-comm" lay-filter="LAY-app-content-comm"></table>
    </div>
    <button class="search-two-btn add-btn batchdelete" data-type="deleteMover" style="margin-top:15px;background:red;">
      <i class="layui-icon layui-icon-delete" style="font-size: 15px; color: #fff;"></i>
      <span style="color:#fff;">删除</span>
    </button>
  </div>
</div>
<script>
  layui.use(
    ["admin", "form", "user", "table", "api", "laytpl", "utill", "laydate"],
    function () {
      var $ = layui.$,
        admin = layui.admin,
        view = layui.view,
        api = layui.api,
        table = layui.table,
        setter = layui.setter,
        laytpl = layui.laytpl,
        utill = layui.utill,
        laydate = layui.laydate,
        form = layui.form;
      form.render(null, "app-content-comment");
      rander();
      function rander(field) {
        var _TPL = {
          fil05: function (d) {
            if (d.fil05 == 0) {
              return "<span>未提交</span>";
            } else if (d.fil05 == 1) {
              return "<span>待审核</span>";
            } else if (d.fil05 == 2) {
              return "<span>待执行</span>";
            } else if (d.fil05 == 6) {
              return "<span>OA送审中</span>";
            } else if (d.fil05 == 9) {
              return "<span>归档/已盘点</span>";
            }
          }
        };
        // 列定制
        utill.columnCustom('#LAY-app-content-comm', "FilFileBGVO", {
          url: api.host + api.selectListDev,
          where: field,
          templet: _TPL
        });
        //隐藏按钮
        utill.showAndHide('.create', 'TcEamReqDevAltController:insertSelectiveBG');//创建按钮
        utill.showAndHide('.batchdelete', 'TcEamReqDevAltController:updateBG');//删除按钮
        table.on("tool(LAY-app-content-comm)", function (obj) {
          var data = obj.data;
          if (obj.event == "detail") {
            if (obj.data.fil05 == 6) {
              location.hash = "/transaction/branch-four/form-four/id=" + obj.data.tcReqId + "/" + "fil01=" + obj
                .data.fil01;
              var href = '[data-jump="transaction/paymentAccount"]';
              sessionStorage.setItem('layui-this', JSON.stringify(href));
            }
            if (obj.data.fil05 == 9) {
              location.hash = "/transaction/branch-four/form-four/id=" + obj.data.tcReqId + "/" + "fil01=" + obj
                .data.fil01;
              var href = '[data-jump="transaction/paymentAccount"]';
              sessionStorage.setItem('layui-this', JSON.stringify(href));
            }
            if (obj.data.fil05 == 0) {
              location.hash = "/transaction/branch-four/form-four-bc/id=" + obj.data.tcReqId + "/" + "fil01=" + obj
                .data.fil01;
              var href = '[data-jump="transaction/paymentAccount"]';
              sessionStorage.setItem('layui-this', JSON.stringify(href));
            }
          }
        });
      }
      form.verify({
            num:[
                /^[\S]{8,99}$/,'请输入申请人工号最少八位,且不能出现空格'
            ]
        })
      var active = {
        query: function () {
          $('.sure').click(function(){
                let val1 = $('#gen02').val()
                $('#gen02').removeAttr('lay-verify');
                if(val1 == ''){
                    
                }else if(val1 != ''){
                    $('#gen02').attr('lay-verify','num');
                }
            })
          $('.boxQuery').css("display", "block");
          // 高查弹窗关闭

          $('.close').click(function(){
              $('#gen02').removeAttr('lay-verify');
              $(".boxQuery").css("display", "none");
          });
          $('.reset').click(function(){
              $('#gen02').removeAttr('lay-verify');
              $("#layuiadmin-form-tags")[0].reset();
              layui.form.render();
          });
          form.on('submit(LAY-submit)', function (data) {
            var field = data.field; //获取提交的字段
            rander(field)
            $(".boxQuery").css("display", "none");
            return false;
          });
        },
        add: function () {
          location.hash = "/transaction/branch-four/add_form";
        },
        // 删除多条数据
        deleteMover: function () {
          var checkStatus = table.checkStatus('#LAY-app-content-comm');
          if (checkStatus.data.length == 0) {
            parent.layer.msg('请至少选择一条数据！', { icon: 2 });
            return;
          }
          var arrs_llp = [];
          var obj = {
            "tcReqId": arrs_llp
          }
          for (var i = 0; i < checkStatus.data.length; i++) {
            arrs_llp.push(checkStatus.data[i].tcReqId);
          }
          admin.req({
            type: 'post',
            dataType: 'json',
            contentType: 'application/json',
            url: api.host + api.delFilFileBG_llp,
            data: JSON.stringify(obj),
            success: function (data) {
              layui.table.reload('#LAY-app-content-comm');
              layer.close(layer.index);
              layer.msg(data.message);
            }
          });
        }
      };

      admin.req({
        url: api.host + api.AzpSelectAzpCoorigCoAlt,
        type: "POST",
        done: function (res) {
          var str = '<option value=""></option>'
          for (let index = 0; index < res.data.length; index++) {
            str = str +
              `<option value="${res.data[index].cooRigId}">${res.data[index].cooRigName}</option>`
          }
          $('#azpa01').append(str)
          form.render(null, 'layuiadmin-form-tags');
        }
      });



      admin.req({
        url: api.host + api.AzpSelectAzpCoorigCoAlt,
        type: "POST",
        done: function (res) {
          var str = '<option value=""></option>'
          for (let index = 0; index < res.data.length; index++) {
            str = str +
              `<option value="${res.data[index].coAltId}">${res.data[index].coAltName}</option>`
          }
          $('#azpb01').append(str)
          form.render(null, 'layuiadmin-form-tags');
        }
      });

      // admin.req({
      //   url: api.host + api.AzpSelectAzpCoorigCoAlt,
      //   type: "POST",
      //   done: function (res) {
      //     var str = '<option value=""></option>'
      //     for (let index = 0; index < res.data.length; index++) {
      //       str = str +
      //         `<option value="${res.data[index].azpName}">${res.data[index].azpName}</option>`
      //     }
      //     $('#azp02').append(str)
      //     form.render(null, 'layuiadmin-form-tags');
      //   }
      // });
      admin.req({
        url: api.host + api.selectApplyer,
        type: "POST",
        done: function (res) {
          var str = '<option value=""></option>'
          for (let index = 0; index < res.data.length; index++) {
            str = str +
              `<option value="${res.data[index].gen02}">${res.data[index].gen02}</option>`
          }
          $('#gen02').append(str);
          form.render(null, 'layuiadmin-form-tags');
        }
      });
      laydate.render({
        elem: `#time`,
        done: function (value, date, endDate) { }
      });
      $(".search-two-btn").on("click", function () {
        var type = $(this).data("type");
        active[type] ? active[type].call(this) : "";
      });
    }
  );
</script>